package de.jmda.mproc.swingui;

import java.io.File;

import javax.swing.DefaultListModel;

import de.jmda.util.fileset.FileSetJavaFilesOnly;

/**
 *
 */
abstract class ListModelJavaSourceFiles extends DefaultListModel
{
  private static final long serialVersionUID = -5003223188520114118L;

	protected FileSetJavaFilesOnly fileSetSources;
	
	protected File[] files;
	
	ListModelJavaSourceFiles(FileSetJavaFilesOnly fileSetSources)
	{
		super();
		this.fileSetSources = fileSetSources;
	}

	@Override
	public String get(int index)
	{
		if (files == null)
		{
			return null;
		}
		else if (files.length == 0)
		{
			return null;
		}

		return files[index].getAbsolutePath();
	}

	@Override
	public Object elementAt(int index)
	{
		return get(index);
	}

	@Override
	public Object getElementAt(int index)
	{
		return get(index);
	}

	@Override
	public int getSize()
	{
		if (files == null)
		{
			return 0;
		}

		return files.length;
	}

	@Override
	public boolean isEmpty()
	{
		if (files == null)
		{
			return true;
		}
		
		if (getSize() == 0)
		{
			return true;
		}

		return false;
	}

	@Override
	public int size()
	{
		return getSize();
	}
}